package com.rays.gank.util

import android.util.Log

/**
 * Created by Rays on 2021/1/23.
 */
object LogUtil {
    const val DEFAULT_TAG = "defaultTag"
    private const val LOG_LEVEL = Log.DEBUG

    fun printLog(
        msg: String,
        tag: String = DEFAULT_TAG,
        tr: Throwable? = null,
        priority: Int = Log.DEBUG
    ) {
        if (priority < LOG_LEVEL) return
        Log.println(
            priority,
            if (tag.isNotBlank()) tag else DEFAULT_TAG,
            if (tr == null) msg else "$msg\n${Log.getStackTraceString(tr)}"
        )
    }
}